
<?php
header("Content-Type:application/json;charset=utf-8");
header('Access-Control-Allow-Origin:*');
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept");
header('Access-Control-Allow-Methods: GET, POST, PUT,DELETE');

@$city = $_REQUEST['city']or die(json_encode(array('responseCode'=>1,'responseMsg'=>'请输入要查询的地址')));;
$post_data = array(); 

$post_data['clientname'] = "test08"; 

$post_data['clientpasswd'] = "test08"; 

$post_data['submit'] = "submit"; 

$url='http://v.juhe.cn/weather/index?cityname='.$city.'&dtype=&format=&key=39423d8dbfb8b760181b72af3f71e92a'; 

$o=""; 

foreach ($post_data as $k=>$v) 

{ 

$o.= "$k=".urlencode($v)."&"; 

} 

$post_data=substr($o,0,-1); 

$ch = curl_init(); 

curl_setopt($ch, CURLOPT_POST, 1); 

curl_setopt($ch, CURLOPT_HEADER, 0); 

curl_setopt($ch, CURLOPT_URL,$url); 

//为了支持cookie 

curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt'); 

curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); 

$result = curl_exec($ch); 
?>